<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2012.03.17.
   家居设计作品列表显示($$)*/

!defined('Q_PATH') && exit;

class Index_C_Controller extends InitController{

	public function index(){
		$nPid=intval(Q::G('pid','G'));
		$nAid=intval(Q::G('aid','G'));
		$nSpid=intval(Q::G('spid','G'));
		$nStid=intval(Q::G('stid','G'));

		// 载入相关缓存
		Core_Extend::loadCache('jiaju_caseclass');
		Core_Extend::loadCache('jiaju_casehotcompany'.Core_Extend::getCityCache());// 热门品牌

		// 当前城市设计作品
		$arrWhere=array();
		$arrWhere['A.jiajucase_status']=1;
		$sCityTitle='';
		if($GLOBALS['_citysitesub_real_']!='www'){
			$arrWhere['string_']=Core_Extend::getCitySql('A.');
			$sCityTitle='#cityname#';
		}

		// 属性筛选
		$sPTitle=$sATitle=$sSpTitle=$sStTitle='';
		if($nPid){
			$arrWhere['A.jiajucase_priceid']=$nPid;
			$sPTitle=Model::F_('jiajucompanyclass','jiajucompanyclass_id=?',$nPid)->getColumn('jiajucompanyclass_name');
		}
		if($nAid){
			$arrWhere['A.jiajucase_areaid']=$nAid;
			$sATitle=Model::F_('jiajucompanyclass','jiajucompanyclass_id=?',$nAid)->getColumn('jiajucompanyclass_name');
		}
		if($nSpid){
			$arrWhere['A.jiajucase_spaceid']=$nSpid;
			$sSpTitle=Model::F_('jiajucompanyclass','jiajucompanyclass_id=?',$nSpid)->getColumn('jiajucompanyclass_name');
		}
		if($nStid){
			$arrWhere['A.jiajucase_styleid']=$nStid;
			$sStTitle=Model::F_('jiajucompanyclass','jiajucompanyclass_id=?',$nStid)->getColumn('jiajucompanyclass_name');
		}

		$nTotal=Model::F_('jiajucase','@A')->where($arrWhere)->getCounts();
		$oPage=Page::RUN($nTotal,12,Jiaju_Extend::getCaseList(null,null,null,null,'{page}',false));
		$arrJiajucases=Model::F_('jiajucase','@A')
			->setColumns('A.jiajucase_pics,A.jiajucase_id,A.jiajucase_title,A.jiajucase_thumb,A.create_dateline,A.jiajucase_likenum,A.jiajucase_designerid,A.user_id,A.jiajucase_picnum,A.jiajucase_commentnum')
			->joinLeft(Q::C('DB_PREFIX').'jiajudesigner AS C','C.jiajudesigner_name AS designer_name','A.jiajucase_designerid=C.jiajudesigner_id')
			->join(Q::C('DB_PREFIX').'jiajucompany AS F','F.jiajucompany_isfvip,F.jiajucompany_id,F.jiajucompany_domain','A.jiajucompany_id=F.jiajucompany_id')
			->where($arrWhere)
			->order('A.jiajucase_id DESC')
			->limit($oPage->S(),$oPage->N())
			->getAll();

		Core_Extend::getSeo($this,array(
			'title'=>($sPTitle?"{$sCityTitle}预算{$sPTitle}装修效果图-":'').
				($sATitle?"{$sCityTitle}{$sATitle}大小装修效果图-":'').
				($sSpTitle?"{$sCityTitle}{$sSpTitle}空间装修效果图-":'').
				($sStTitle?"{$sCityTitle}{$sStTitle}风格装修效果图-":'').
				"{$sCityTitle}装修效果图-{$sCityTitle}装修样板案例-{$sCityTitle}装修设计作品精选",
			'keywords'=>($sPTitle?"{$sCityTitle}预算{$sPTitle}装修效果图,":'').
				($sATitle?"{$sCityTitle}{$sATitle}大小装修效果图,":'').
				($sSpTitle?"{$sCityTitle}{$sSpTitle}空间装修效果图,":'').
				($sStTitle?"{$sCityTitle}{$sStTitle}风格装修效果图,":'').
				"{$sCityTitle}装修效果图,{$sCityTitle}装修样板案例,{$sCityTitle}装修设计作品精选",
			'description'=>($sPTitle?"{$sCityTitle}预算{$sPTitle}装修效果图-":'').
				($sATitle?"{$sCityTitle}{$sATitle}大小装修效果图-":'').
				($sSpTitle?"{$sCityTitle}{$sSpTitle}空间装修效果图-":'').
				($sStTitle?"{$sCityTitle}{$sStTitle}风格装修效果图-":'').
				"#sitename#装修效果图专区,提供".date('Y')."年国内外最新流行的装修效果图和装修样板案例,最新的设计灵感，最新的装饰布置，让您的家庭装修梦想顺利达成。",
		),true,true);

		$this->assign('arrJiajucases',$arrJiajucases);
		$this->assign('sPageNavbar',$oPage->P(array('id'=>'pagination','style'=>'li','current'=>'active')));
		$this->assign('arrCaseClasss',$GLOBALS['_cache_']['jiaju_caseclass']);
		$this->assign('arrHotPingpaiJiajucompanys',$GLOBALS['_cache_']['jiaju_casehotcompany'.Core_Extend::getCityCache()]);
		$this->assign('sPTitle',$sPTitle);
		$this->assign('sATitle',$sATitle);
		$this->assign('sSpTitle',$sSpTitle);
		$this->assign('sStTitle',$sStTitle);
		$this->display();
	}

}
